//package com.ruoyi.project.bi.util;
//
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * 跨域请求设置Filter
// * @author gdp
// * @Date 2020/9/18 9:38 上午
// */
//@Component
//public class HeadFilter implements Filter  {
//
//    @Override
//    public void destroy() {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse resp, FilterChain chain)
//            throws IOException, ServletException {
//        HttpServletResponse response=(HttpServletResponse)resp;
//        HttpServletRequest req = (HttpServletRequest)request;
//        String origin = req.getHeader("Origin");
//        if(origin == null) {
//            origin = req.getHeader("Referer");
//        }
//        response.setHeader("Access-Control-Allow-Headers", "Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild");
//        response.setHeader("Access-Control-Allow-Origin", origin);//这里不能写*，*代表接受所有域名访问，如写*则下面一行代码无效。谨记
//        response.setHeader("Access-Control-Allow-Credentials", "true");//true代表允许携带cookie
//        chain.doFilter(req, response);
//    }
//
//    @Override
//    public void init(FilterConfig arg0)
//            throws ServletException {
//    }
//
//}
